﻿using Microsoft.AspNetCore.Mvc;
using Model;
using Services;

namespace Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TableController : ControllerBase
    {
        private readonly ITableInfoService sysTableInfo;

        public TableController(ITableInfoService _sysTableInfo)
        {
            sysTableInfo = _sysTableInfo;
        }

        [HttpPost]
        public MessageModel LoadTable(GetTableDto dto)
        {
            if (string.IsNullOrEmpty(dto.Id) || string.IsNullOrEmpty(dto.TableName))
            {
                return new MessageModel() { msg = "参数不能为空!" };
            }

            var data = sysTableInfo.LoadTable(dto);

            MessageModel message = new MessageModel()
            {
                msg = "获取成功!",
                data = data,
                success = true
            };

            return message;
        }

    }
}
